## Example of PGZ and PGZm decoding


from PyM import *


# Example PGZ (Maria Bras, Example, page 10)#

K = Zn(3)
[F,a] = extension(K,[1,0,-1,1],'a','F')  
show(F)
b = a**2
C = BCH(b,5,3)
H = H_(C)

# Two errors in the base field
y = vec([0,0,0,0,0,0,1,0,0,2,0,0,0],K)
s = y * transpose(H)
show(s)

show(PGZ(clone(y),C))

show(PGZm(clone(y),C))

show(BMS(clone(y),C),nl=2)

# The algorithms also work for two errors in F
y = vector([0,0,0,0,0,0,b,0,0,b**12,0,0,0])
s = y * transpose(H)
show(s)
show(vector([a**2,a**3,a**23,a**7])) # to check in original example


show(PGZ(clone(y),C))

show(PGZm(clone(y),C))

show(BMS(clone(y),C))